package singleton;

//静态内部类
public class CreatSingleton2 {
    private static CreatSingleton2 singleton;
    private CreatSingleton2() {
        System.out.println(Thread.currentThread().getName()+"正在调用构造方法");
    }

    public static class CreatSingleton2Instance{
        private static CreatSingleton2 singleton2 = new CreatSingleton2();
    }
    public static CreatSingleton2 getSingleton() {
        return CreatSingleton2Instance.singleton2;
    }
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                CreatSingleton2.getSingleton();
            },String.valueOf(i)).start();

        }
    }
}
